package com.xiaotao.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class UserUtil {
    public static Integer UserContext() throws Exception {
        ServletRequestAttributes redirectAttribute= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request=redirectAttribute.getRequest();
        String token = request.getHeader("token");
        Integer userId = JwtUtil.getUserId(token);
        return userId;
    }
}
